# -*- coding: utf-8 -*-
"""
应用配置文件
包含所有环境变量和配置项
"""

import os
from typing import List
from pydantic import ConfigDict, Field
from pydantic_settings import BaseSettings


class Settings(BaseSettings):
    """
    应用配置类
    使用pydantic进行配置管理和验证
    """
    
    # 项目基本信息
    PROJECT_NAME: str = "API测试Demo"
    PROJECT_DESCRIPTION: str = "用于接口测试的FastAPI示例项目"
    VERSION: str = "1.0.0"
    
    # API配置
    API_V1_STR: str = "/api/v1"
    
    # 服务器配置
    HOST: str = "0.0.0.0"
    PORT: int = 8000
    DEBUG: bool = True
    
    # CORS配置
    ALLOWED_HOSTS: List[str] = ["*"]
    
    # 数据库配置（示例，当前使用内存存储）
    DATABASE_URL: str = "sqlite:///./test.db"
    
    # 日志配置
    LOG_LEVEL: str = "INFO"
    LOG_FORMAT: str = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
    
    # 测试配置
    TESTING: bool = False
    TEST_DATABASE_URL: str = "sqlite:///./test_db.db"
    
    # DeepSeek API配置
    DEEPSEEK_API_KEY: str = Field(default="sk-your-deepseek-api-key-here", description="DeepSeek API密钥")
    DEEPSEEK_BASE_URL: str = Field(default="https://api.deepseek.com", description="DeepSeek API基础URL")
    DEEPSEEK_MODEL: str = Field(default="deepseek-chat", description="DeepSeek模型名称")
    DEEPSEEK_MAX_TOKENS: int = Field(default=1000, description="最大token数量")
    DEEPSEEK_TEMPERATURE: float = Field(default=0.7, description="温度参数")
    
    model_config = ConfigDict(
        env_file=".env",
        env_file_encoding="utf-8",
        case_sensitive=True
    )


# 创建全局配置实例
settings = Settings()